<template>
	<view>
		<view class="Germany"  
		 v-for="(item, index) in items"
         :key="index"
         :style="{ backgroundColor: getBackgroundColor(index)}" @click="NAVPAGE(`/pages/content/akalisa/akalisa?type=BJ&ids=${item.id}`)">
		 
			<view class="manual">
				<view class="weapons">
				    {{item.bank_name}} 
				</view>
				<view class="magic">
					 {{item.bank_code}} 
				</view>
			</view>
			<view class="unions">
				<view class="interpersonal">
				    {{item.username}} 
				</view>
				<view class="behalf">
					 {{item.phone}}
				</view>
			</view>
			<view @click.stop="deleteBankCard(item.id, index)" class="intercept" size="mini" style="margin-left: 10rpx;">删除</view>
		</view>
		<view class="" style="height: 150rpx;"></view>
		
		<u-empty v-if="items.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
		</u-empty>
		
		<view class="Avatar">
			<u-button @click="NAVPAGE('/pages/content/akalisa/akalisa?type=TJ')" text="添加银行卡" shape="circle" color="#ff6600"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: []
			}
		},
		onLoad() {
			this.courier()
		},
		onShow() {
			this.courier()
		},
		methods: {
			courier() {
				this.$api.information().then(res => {
					console.log(res, 'res')
					this.items = res.data
				})
			},
			getBackgroundColor(index) {
				const colors = ["#ff6600", "#ff6600", "#ff6600", "#ff6600"];
				return colors[index % colors.length]; // 循环使用颜色
			},
			deleteBankCard(id, index) {
				// 调用API删除银行卡
				this.$api.deleteBankCard({id:id}).then(res => {
					if(res.code == 1){
						uni.showToast({
							title:res.info,
							icon:'none'
						})
						
						this.courier()
					}
				}).catch(err => {
					console.error('网络错误:', err);
				});
			}
		}
	}
</script>

<style lang="scss">
	page {}
	.Germany {
		border-radius: 20rpx;
		padding: 20rpx;
		margin: 20rpx;
		background-color: #ff6600;
		.manual, .unions {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 10rpx;
			.weapons, .magic {
				color: #fff;
				height: 42rpx;
				font-family: MiSans, MiSans;
				font-weight: 500;
				font-size: 32rpx;
				line-height: 42rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
			}
			.interpersonal {
				color: #ffffff;
			}
			.behalf {
				color: #f1f1f1;
			}
		}
		.intercept{
			font-size: 28rpx;
			color: #fff;
			border-radius: 100rpx;
			padding: 10rpx 0rpx;
		}
	}
	.Avatar{
		position: fixed;
		bottom: 0rpx;
		padding: 22rpx 38rpx;
		background-color: #fff;
		width: 90%;
		text-align: center;
		z-index: 999;
	}
</style>